package cloudy.trident.tools;

import org.apache.storm.trident.operation.BaseFunction;
import org.apache.storm.trident.operation.TridentCollector;
import org.apache.storm.trident.tuple.TridentTuple;
import org.apache.storm.tuple.Values;

/**
 * @Name cloudy.trident.tools.Print
 * @Description
 * @Author Elwyn
 * @Version 2017/9/30
 * @Copyright 上海云辰信息科技有限公司
 **/
public class SplitBy extends BaseFunction {
	private String patten;

	public SplitBy(String patten) {
		this.patten = patten;
	}

	@Override
	public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
		if (!tridentTuple.isEmpty()){
			String string = tridentTuple.getString(0);
			String value[] = string.split(patten);
				tridentCollector.emit(new Values(value[0],value[1]));
		}
	}
}
